<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div style="border-radius:2px;margin-bottom:10px;background:#f5f5f5;padding:2% 5%;">
        <div class="row" style="">
            <!--部门-->
            <label class="control-label col-xs-12 col-sm-1"><span style="color:red;">*</span>{:__('Depart_name')}:</label>
            <div class="form-group col-xs-12 col-sm-2">
                <!--数据排序-->
                <input id="c-depart_name" data-source="setting/basicinformation/departs" data-field="depart_code" data-pagination="true" data-page-size="5" data-order-by="id" data-primary-key="depart_code" class="form-control selectpage" name="row[depart_name]" type="text" placeholder="--请选择部门--">
            </div>
            <!--需求日期-->
            <label class="control-label col-xs-12 col-sm-1"><span style="color:red;">*</span>{:__('Need_time')}:</label>
            <div class="form-group col-xs-12 col-sm-2">
                <input id="c-need_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[need_time]" type="text" value="{:date('Y-m-d H:i:s')}">
            </div>
            <!--订单类型-->
            <label class="control-label col-xs-12 col-sm-1"><span style="color:red;">*</span>{:__('Order_type')}:</label>
            <div class="form-group col-xs-12 col-sm-2">
                <select  id="c-order_type" data-rule="required" class="form-control selectpicker" name="row[order_type]">
                    {foreach name="orderTypeList" item="vo"}
                    <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <!--备注-->
        <div class="row" style="">
            <label class="control-label col-xs-12 col-sm-1">{:__('Remark')}:</label>
            <div class="form-group col-xs-12 col-sm-5">
                <input id="c-remark" class="form-control" name="row[remark]" type="text">
            </div>
        </div>

        <div class="form-group layer-footer">
            <label class="control-label col-xs-12 col-sm-2"></label>
            <div class="col-xs-12 col-sm-8">
                <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
                <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
            </div>
        </div>
        <!--行-->
        <div class="form-group row">
            <div>
                <!--data-template的值作为行中的id值，才能便于追加行与引用-->
                <table class="table fieldlist" data-template="linedetail" data-name="linedetail" id="linetable" >
                    <thead>
                    <tr class="info">
                        <th>行号</th>
                        <th>工单号</th>
                        <th>料号<span style="color:red;">*</span></th>
                        <th>料号名称</th>
                        <th>规格型号</th>
                        <th>单位</th>
                        <th>数量<span style="color:red;">*</span></th>
                        <th>长</th>
                        <th>宽</th>
                        <th>高</th>
                        <th>重量</th>
                        <th>备注</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <!--name中<%=name%>表示的是data-template为此地的id值linedetail,对应的data-name的值linedetail-->
                    <script id="linedetail" type="text/html">
                        <tr class="active">
                            // <%=name%>[<%=index%>][line]表示该编程语言中调用由名称为“name”的变量中的索引为“index”的元素的对应的行号。
                            //var obj = {'line':'','stockid':'','item_name':'','uom':'','ship_flag':'','need_time':'','quantity':'','price':'','line_amount':'','line_remark':''};
                            // 行号
                            <td style="width:75px">
                                <input type="text" readonly="readonly" class="form-control" name="<%=name%>[<%=index%>][line]" value="1"/>
                            </td>
                            // 工单号
                            <td class="form-group">
                                <input data-rule="required" type="text" class="form-control"  name="<%=name%>[<%=index%>][wip_entity_name]"/>
                            </td>
                            // 料号
                            <td>
                                <input type="text" id="item_no<%=index+1%>" data-url="popup/purchase/itemno/select" class="form-control fachoosetable"  data-line="<%=index+1%>" name="<%=name%>[<%=index%>][item_no]"/>
                            </td>
                            // 料号名称
                            <td>
                                <input type="text" class="form-control" id="item_name<%=index+1%>" name=""  />
                            </td>
                            // 规格型号
                            <td>
                                <input type="text" class="form-control" id="item_desc<%=index+1%>" name=""  />
                            </td>
                            // 单位
                            <td>
                                <input type="text" class="form-control" id="units<%=index+1%>" name="" />
                            </td>
                            // 数量
                            <td style="width:100px" class="form-group">
                                <input data-rule="required" id="quantity<%=index+1%>" type="text" class="form-control all_quantity"  name="<%=name%>[<%=index%>][quantity]"/>
                            </td>
                            // 长
                            <td>
                                <input type="text" class="form-control"  name="<%=name%>[<%=index%>][chang]"  />
                            </td>
                            // 宽
                            <td>
                                <input type="text" class="form-control"  name="<%=name%>[<%=index%>][kuan]"  />
                            </td>
                            // 高
                            <td>
                                <input type="text" class="form-control"  name="<%=name%>[<%=index%>][gao]"  />
                            </td>
                            // 重量
                            <td>
                                <input type="text" class="form-control"  name="<%=name%>[<%=index%>][weight]"  />
                            </td>
                            // 备注
                            <td>
                                <input type="text" class="form-control"  name="<%=name%>[<%=index%>][remark]"/>
                            </td>

                            //请购单号
                            <td style="display:none">
                                <input type="hidden" class="form-control"  name="<%=name%>[<%=index%>][pr_num]"/>
                            </td>
                            <td>
                                <span class="btn btn-sm btn-danger btn-removeline"><i class="fa fa-times"></i></span>
                            </td>
                        </tr>
                    </script>


                    </tbody>
                    <tr>
                        <td colspan="1"><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plas"></i>添加行</a></td>
                        <td colspan="6">{:__('总计数量')}:<input id="all_quantity" type="text" name="all_quantity" readonly="readonly" style="width:80px;border-width:0px"/></td>
                    </tr>
                </table>
                <!--请注意实际开发中textarea应该添加个hidden进行隐藏-->
                <textarea id="textarea1" name="linedetail" class="form-control hidden" cols="30" rows="5"></textarea>
            </div>
        </div>
</form>
